#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int count[6];
int main(int argc, char** argv) {
    int n;
    cin>>n;
    int t;
    for (int i=0; i<n; ++i) {
        scanf("%d", &t);
        ++count[t];
    }
    int res = 0;
    res += count[5];
    res += count[4];
    count[1] -= count[4];
    if (count[1]<0) count[1] = 0;
    res += count[3];
    count[2] -= count[3];
    if (count[2] < 0) {
        count[1] += 2*count[2];
        count[2] = 0;
        if (count[1] < 0) count[1] = 0;
    }
    res += count[2]/2;
    count[1] -= count[2]/2;
    if (count[1] < 0) count[1] = 0;
    if (count[2]%2) {
        ++res;
        count[1] -= 3;
        if (count[1]<0) count[1] = 0;
    }
    res += count[1]/5;
    if (count[1]%5) ++res;
    cout<<res<<endl;
    return 0;
}
